<template>
    <div>
    <h1>病房信息添加</h1>
    <table class="table">
        <thead>
           
            <tr>
                <td>科室名称</td>
                <td>
                    <input type="text" v-model="data.name">
                </td>
            </tr>
          
            <tr>
                <td>科室人数</td>
                <td>
                    <input type="text" v-model="data.program">
                </td>
            </tr>
            <tr>
                <td>科室描述</td>
                <td>
                    <input type="text" v-model="data.miaoshu">
                </td>
            </tr>
          
            <tr>
                <td>创建日期</td>
                <td>
                    <input type="date" v-model="data.startTime">
                </td>
            </tr>
            <tr>
                
                <td colspan="2">
                    <input type="button" value="修改" @click="Add">
                </td>
            </tr>
        </thead>
    </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from "vue"
import axios from "axios";
import moment from "moment";
import { useRoute } from "vue-router";
const route=useRoute()
const Fantian=()=>{
    var x=route.query.id
    axios.get("https://localhost:7140/api/RoomClass/Fantian",{params:{id:x}}).then(res=>{
        data.value=res.data
        data.value.startTime=moment(data.value.startTime).format("YYYY-MM-DD")
    })
}
const data=ref({
    "cid": 0,
  "name": "",
  "program": 0,
  "miaoshu": "",
  "startTime": "2025-05-19T03:03:04.288Z",
  "isDelete": true
})
onMounted(()=>{
    Fantian()
})
const Add=()=>{
  
    axios.put("https://localhost:7140/api/RoomClass/UptRoom",data.value).then(res=>{
    if(res.data>0){
        alert('修改成功');
        location.href='/ShowClassView';
    }
    else{
        alert('修改失败');
    }
    })
}
</script>

<style scoped>

</style>